package common;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;

import java.time.Duration;

public class UtilsMatch {
    public static  WebDriver driverChrome;
    public static  WebDriver driverEdge;

    public UtilsMatch(String str1,String str2){
        driverChrome=createDriverChrome();
        driverEdge=createDriverEdge();
        driverEdge.get(str1);
        driverChrome.get(str2);
    }

    public WebDriver createDriverChrome(){
        if (driverChrome==null){
            WebDriverManager.chromedriver().setup();
            ChromeOptions options=new ChromeOptions();
            options.addArguments("--remote-allow-origins=*");
            driverChrome=new ChromeDriver(options);

            //隐式等待
            driverChrome.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
        }
        return driverChrome;
    }

    public WebDriver createDriverEdge(){
        if (driverEdge==null){
            WebDriverManager.edgedriver().setup();
            EdgeOptions options=new EdgeOptions();
            options.addArguments("--remote-allow-origins=*");
            driverEdge=new EdgeDriver(options);
            driverEdge.manage().timeouts().implicitlyWait(Duration.ofSeconds(3));
        }
        return driverEdge;
    }
}
